package com.xx.pmis.services.implementations;

import java.util.List;

import com.xx.pmis.model.Account;
import com.xx.pmis.persistence.dao.AccountDAO;
import com.xx.pmis.services.AccountService;

public class AccountServiceImpl implements AccountService {
	AccountDAO accountDAO = null;

	public AccountServiceImpl(AccountDAO accountDAO) {
		super();
		this.accountDAO = accountDAO;
	}

	public void saveOrUpdateAccount(Account account) throws Exception {
		accountDAO.saveOrUpdate(account);
	}

	public void saveAccount(Account account) throws Exception {
		accountDAO.save(account);
	}

	public void deleteAccount(Account account) throws Exception {
		accountDAO.delete(account);
	}

	public Account getAccountByAccountID(String accountID) throws Exception {
		Account account = accountDAO.getAccountByAccountID(accountID);
		return account;
	}

	public List<Account> getAllAccountByCondition(String hql) throws Exception {
		List<Account> accounts = accountDAO.getAllAccountByCondition(hql);
		return accounts;
	}

	public List<Account> getAllAccountByConditionByPage(String hql, int currentPage, int lineSize) throws Exception {
		List<Account> accounts = accountDAO.getAllAccountByConditionByPage(hql, currentPage, lineSize);
		return accounts;
	}

	public int getCountOfAccountByCondition(String hql) throws Exception {
		return getAllAccountByCondition(hql).size();
	}

	public String getMaxAccountCodeFromAccount() throws Exception {
		String accountCode = accountDAO.getMaxAccountCodeFromAccount();
		return accountCode;
	}
	
	public Account getAccountByAccountCode(String accountCode) throws Exception {
		Account account = accountDAO.getAccountByAccountCode(accountCode);
		return account;
	}

}
